package com.example.java.Mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.java.Entity.Admin;

import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminMapper extends BaseMapper<Admin> {

    //    查询所有
    @Select("select * from admin")
    List<Admin> alladmin();

    //    增加或修改
    @Insert("INSERT into admin (name,username,password,avatar) VALUES (#{name},#{username},#{password},#{avatar})")
    int insert(Admin admin);

    @Insert("update admin set name = #{name}, username = #{username}, password = #{password}, avatar = #{avatar} where id = #{id}")
    int updata(Admin admin);

    //    通过id删除
    @Delete("delete from admin where id = #{id}")
    Integer deleteById(@Param("id") Integer id);

    //    名字模糊查询
    @Select("SELECT * FROM admin WHERE (admin.name LIKE CONCAT('%',#{keyword},'%') OR admin.username LIKE CONCAT('%',#{keyword},'%'))")
    List<Admin> getLike(String keyword);
}
